# -*- encoding=utf8 -*-
"""
RedFlag-TC000090  （拍摄进入装饰页）剪辑保存功能
分割撤销场景
变速撤销场景
音量撤销场景
旋转撤销场景
铺满撤销场景
复制撤销场景
倒放撤销场景
删除撤销场景
保存视频场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *

auto_setup(__file__)
shooter = CameraVideoShooter()
log("--------------------------------分割撤销场景--------------------------------------")
"""
拍摄视频进入装饰页
点击剪辑
滑动视频条
点击分割
点击撤销
断言
"""

shooter.enter_photography_decoration_page()
shooter.click_element(edit_button)
sleep(2.0)
shooter.swipe_screen((0.8,0.75),(0.6,0.75))
shooter.click_element(edit_segmentation)
shooter.assert_toast_popup(edit_revoke,r"tpl1748265592989.png", "断言失败，预期撤销toast并未出现", record_pos=(-0.001, 0.758), threshold=0.3, high_freq_interval=0.01, high_freq_timeout=3)

log("--------------------------------变速撤销场景--------------------------------------")
"""
点击变速
选择一个速度
点击保存
点击撤销
断言
"""

shooter.click_element(edit_variable_speed)
touch((0.12,0.93))
shooter.click_element(edit_variable_speed_confirm)
shooter.click_element(edit_revoke)
shooter.assert_image_exists(r"tpl1748265616859.png", "断言失败，预期撤销toast并未出现", record_pos=(-0.002, 0.758))

log("--------------------------------音量撤销场景--------------------------------------")
"""
点击音量
选择一个音量
点击保存
点击撤销
断言
"""

shooter.click_element(edit_volume)
touch((0.3,0.9))
shooter.click_element(edit_volume_confirm)
shooter.click_element(edit_revoke)
shooter.assert_image_exists(r"tpl1748265664434.png", "断言失败，预期撤销toast并未出现", record_pos=(0.0, 0.761))

log("--------------------------------旋转撤销场景--------------------------------------")
"""
点击旋转
点击撤销
断言
"""

shooter.click_element(edit_rotate)
shooter.click_element(edit_revoke)
shooter.assert_image_exists(r"tpl1748265681169.png", "断言失败，预期撤销toast并未出现", record_pos=(-0.002, 0.757))

log("--------------------------------铺满撤销场景--------------------------------------")
"""
点击旋转
点击撤销
断言
"""

shooter.click_element(edit_cover)
shooter.click_element(edit_revoke)
shooter.assert_image_exists(r"tpl1748265702208.png", "断言失败，预期撤销toast并未出现", record_pos=(-0.004, 0.757))

log("--------------------------------复制撤销场景--------------------------------------")
"""
点击复制
点击撤销
断言
"""

shooter.click_element(edit_copy)
shooter.click_element(edit_revoke)
shooter.assert_image_exists(r"tpl1748265720376.png", "断言失败，预期撤销toast并未出现", record_pos=(-0.002, 0.76))

log("--------------------------------倒放撤销场景--------------------------------------")
"""
点击复制
点击撤销
断言
"""

shooter.click_element(edit_inverted)
sleep(5)
shooter.click_element(edit_revoke)
shooter.assert_image_exists(r"tpl1748265755891.png", "断言失败，预期撤销toast并未出现", record_pos=(-0.001, 0.758))

log("--------------------------------删除撤销场景--------------------------------------")
"""
点击复制
点击撤销
断言
"""

shooter.click_element(edit_copy)
shooter.click_element(edit_delete)
shooter.click_element(edit_revoke)
shooter.assert_image_exists(r"tpl1748265780454.png", "断言失败，预期撤销toast并未出现", record_pos=(0.002, 0.758))

log("--------------------------------剪辑保存场景--------------------------------------")
"""
点击保存
断言
"""

shooter.click_element(edit_save)
shooter.assert_element_exists(decoration_page_release_video, "断言失败，并未找到发布元素")

# 关闭应用
stop_app(UGC_package_name)